import socket
import threading
from time import sleep

def recv (conn,addr):
    while True:
        try:
            data = conn.recv(1024).decode("utf-8")
            if len(data)>0 :
                print(data)
            sleep(0.1)
            # send = data.encode("utf-8")
            # conn.send(send)
        except Exception as e:
            print(e)
            conn.close()
            return

client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
client.connect(("120.77.205.203",54321))
threading.Thread(target=recv,args=(client,None)).start()
while True:
    client.send("hello world!".encode("utf-8"))
    sleep(5)

client.close()